/*
 * MIT License
 *
 * Copyright (c) 2023 北京凯特伟业科技有限公司
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package com.je.message.vo;

import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiMessageCorpconversationAsyncsendV2Request;

import java.util.List;

public class MessageVo {
    //----------welink---------------------------------------------------
    /**
     * 消息发送方，如“考勤”，长度不超过18字节。
     */
    private String msgOwner;

    /**
     * 接收消息的公众号ID，不传则默认发送消息到通知中心；可以在管理后台-公众号-公众号设置找到公众号ID
     */
    private String publicAccID;

    /**
     * 	0:按用户推送;1:按部门发送;2:按角色发送；默认0:按用户推送
     */
    private String msgRange;

    /**
     * 	接收消息的部门ID（多个接收者用','分隔，最多支持100个）；msgRange=1时必传
     */
    private String departmentList;

    /**
     * 	接收消息的角色ID（多个接收者用','分隔，最多支持100个）；msgRange=2时必传
     */
    private String roleList;

    /**
     * 	消息标题，长度不超过128字节。
     * 如仅展示中文消息，可直接传普通string，如 “出差电子流” 。
     * 需要双语则参考请求包体示例，传入json类型的string。
     */
    private String msgTitle;

    /**
     * 消息内容，长度不超过512字节。
     * 如仅展示中文消息，可直接传普通string，如 “张三提交了一个去上海的出差申请” 。
     * 需要双语则参考请求包体示例，传入json类型的string。
     */
    private String msgContent;

    /**
     * 接收消息终端，0 ：PC；1 ：Mobile；2 ：PC+MOBILE（默认）
     */
    private String receiveDeviceType;

    /**
     * 链接类型定义。当前只支持“html”，点击后跳转到相关链接
     */
    private String urlType;

    /**
     * 点击消息，跳转的链接
     */
    private String urlPath;

    /**
     * PC端消息跳转链接。
     * 非必填，当receiveDeviceType配置为0和2时，需要配置该参数，如果不配置就默认使用urlPath
     */
    private String desktopUrlPath;

    /**
     * 消息状态，具体显示见样例图片（PC端不支持，移动端从5.45.X版本开始支持）。
     * 格式："messageStatus":"{"EN":"processed","CN":"已处理"}",
     * 其中CN长度: 2-5个字; EN长度: 2-10个字符。
     */
    private String messageStatus;

    /**
     * 状态对应的颜色（PC端不支持，移动端从5.45.X版本开始支持）
     * 支持三种颜色0 (灰色), 1（黄色）, 2（绿色）；默认：0
     */
    private String statusColor;

    /**
     * 是否强提醒。
     * 强提醒时PC WeLink收到消息，屏幕右下角会有弹窗提示。0：否；1：是。为空时默认为0，不强提醒
     */
    private String isForceTips;

    //----------fs----------------------------------------------------------

    /**
     * 消息类型   文字：text  图片：image 富文本：post 分享群名片：share_chat 卡片消息：interactive 分享个人名片：share_user
     *           语音：audio 视频：media 文件：file 表情包：sticker
     */
    private String fsMsgType;
    /**
     * 内容
     */
    private String content;
    /**
     * 文件 语音 图片 表情包 视频 地址
     */
    private String fileKey;
    /**
     * 集团公司ID
     */
    private String jtgsId;
    /**
     * 按钮
     */
    private String buttonText;
    /**
     * 链接
     */
    private String url;
    /**
     * 原文链接地址
     */
    private String sourceUrl;

    //----------dd---------------------------------------------------------
    /**
     * 接收用户 如果值为@all 则发送给全部的人
     */
    private String userIds;
    /**
     * 接收部门
     */
    private String deptIds;
    /**
     * 消息类型  钉钉 ：文字：WZ  图片：TP 语音：YY  文件：WJ markdown:MD OA:OA 卡片：KP 链接LJ
     *         微信 ：文字：WZ  图文：TW 图片：TP 语音：YY 视频：SP 文件：WJ
     *         welink：普通卡片 common 、 //TODO 应用卡片 wecode 、图片消息 image 、图文消息 news
     *
     */
    private String msgType;
    /**
     * 附件名称
     */
    private String fileName;
    /**
     * Markdown Text
     */
    private String mdText;
    /**
     * 标题
     */
    private String title;

    /**
     * 作者
     */
    private String author;

    /**
     * OA消息PCURL
     */
    private String pcUrl;
    /**
     * OA移动端URL
     */
    private String mobileUrl;

    /**
     * OA消息头部的背景颜色
     */
    private String bgColor;

    /**
     * OA消息表单内容-最多显示6个
     */
    private List<OapiMessageCorpconversationAsyncsendV2Request.Form> listFrom;

    /**
     * OA消息体的标题
     */
    private String bodyTitle;

    /**
     * OA消息自定义的附件数目。此数字仅供显示，钉钉不作验证
     */
    private String fileCount;
    /**
     * OA消息单行富文本信息的数目
     */
    private String richNum;
    /**
     * OA消息单行富文本信息的单位
     */
    private String richUnit;
    /**
     * 消息体的关键字
     */
    private String formKey;
    /**
     * 消息体的关键字对应的值
     */
    private String formValue;

    /**
     * 使用独立跳转ActionCard样式时的按钮排列方式，竖直排列(0)，横向排列(1)；
     */
    private String btnOrientation;

    /**
     * 卡片按钮集合
     */
    private List<OapiMessageCorpconversationAsyncsendV2Request.BtnJsonList> btnJsonList;

    //----------wx--------------------------------------------------
    /**
     * 图文类型  UEditor 编辑器内容 || HTML || URL 链接
     */
    private String twType;
    /**
     * 作者
     */
    private String remark;

    private String errorMessage;
    private String result;

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }

    public MessageVo() {
    }

    public MessageVo(String userIds, String type, String context) {
        this.userIds = userIds;
        this.msgType = type;
        this.content = context;
    }

//    //微信图文
//    public MessageVo(String userIds, String type, String twType, String title, String author, String remark, String context, String picPath) {
//        this.userIds = userIds;
//        this.msgType = type;
//        this.twType = twType;
//        this.title = title;
//        this.author = author;
//        this.remark = remark;
//        this.content = context;
//        this.fileKey = picPath;
//    }

    /**
     * 图片/语音/MD/文件 微信图片 视频 钉钉图片 语音 文件 md
     *
     * @param userIds          用户
     * @param type             类型
     * @param filePathOrMdText 附件地址或者MD内容
     * @param fileNameOrMdName 附件名称或者MD标题
     */
    public MessageVo(String userIds, String type, String filePathOrMdText, String fileNameOrMdName) {
        this.userIds = userIds;
        this.msgType = type;
        if (type.equals("MD")) {
            this.content = filePathOrMdText;
            this.title = fileNameOrMdName;
        } else {
            this.mdText = filePathOrMdText;
            this.content = filePathOrMdText;
            this.fileName = fileNameOrMdName;
            this.fileKey = fileNameOrMdName;
        }
    }

    /**
     * 卡片 钉钉 卡片
     *
     * @param userIds        用户
     * @param type           类型
     * @param cardTitle      标题
     * @param markDownText   内容
     * @param btnOrientation 按钮排列方式
     * @param btnJsonList    按钮集合
     */
    public MessageVo(String userIds, String type, String cardTitle, String markDownText, String btnOrientation,
                     List<OapiMessageCorpconversationAsyncsendV2Request.BtnJsonList> btnJsonList) {
        this.userIds = userIds;
        this.msgType = type;
        this.title = cardTitle;
        this.content = markDownText;
        this.btnOrientation = btnOrientation;
        this.btnJsonList = btnJsonList;
    }

    /**
     * 链接  钉钉
     *
     * @param userIds  用户
     * @param type     类型
     * @param fileKey  附件KEY
     * @param fileName 附件名称
     * @param title    标题
     * @param text     内容
     * @param url      地址
     */
    public MessageVo(String userIds, String type, String fileKey, String fileName, String title, String text, String url) {
        this.userIds = userIds;
        this.msgType = type;
        this.fileKey = fileKey;
        this.fileName = fileName;
        this.title = title;
        this.content = text;
        this.url = url;
    }

    /**
     * OA  钉钉
     *
     * @param userIds     用户
     * @param type        类型
     * @param fileKey     附件KEY
     * @param fileName    附件名称
     * @param url         移动端url
     * @param pcUrl       pcURL
     * @param headText    表头标题
     * @param headColor   表头背景色
     * @param listFrom    表单内容 key：value
     * @param richNum     rich数目
     * @param richUnit    rich单位
     * @param bodyContent 内容
     * @param bodyTitle   表单标题
     * @param fileCount   附件数量
     * @param author      作者
     */
    public MessageVo(String userIds, String type, String fileKey, String fileName, String url, String pcUrl, String headText,
                     String headColor, List<OapiMessageCorpconversationAsyncsendV2Request.Form> listFrom, String richNum, String richUnit, String bodyContent, String bodyTitle, String fileCount, String author) {
        this.userIds = userIds;
        this.msgType = type;
        this.fileKey = fileKey;
        this.fileName = fileName;
        this.mobileUrl = url;
        this.pcUrl = pcUrl;
        this.title = headText;
        this.bgColor = headColor;
        this.listFrom = listFrom;
        this.richNum = richNum;
        this.richUnit = richUnit;
        this.content = bodyContent;
        this.bodyTitle = bodyTitle;
        this.fileCount = fileCount;
        this.author = author;
    }

    public String getMsgOwner() {
        return msgOwner;
    }

    public void setMsgOwner(String msgOwner) {
        this.msgOwner = msgOwner;
    }

    public String getPublicAccID() {
        return publicAccID;
    }

    public void setPublicAccID(String publicAccID) {
        this.publicAccID = publicAccID;
    }

    public String getMsgRange() {
        return msgRange;
    }

    public void setMsgRange(String msgRange) {
        this.msgRange = msgRange;
    }

    public String getDepartmentList() {
        return departmentList;
    }

    public void setDepartmentList(String departmentList) {
        this.departmentList = departmentList;
    }

    public String getRoleList() {
        return roleList;
    }

    public void setRoleList(String roleList) {
        this.roleList = roleList;
    }

    public String getMsgTitle() {
        return msgTitle;
    }

    public void setMsgTitle(String msgTitle) {
        this.msgTitle = msgTitle;
    }

    public String getMsgContent() {
        return msgContent;
    }

    public void setMsgContent(String msgContent) {
        this.msgContent = msgContent;
    }

    public String getReceiveDeviceType() {
        return receiveDeviceType;
    }

    public void setReceiveDeviceType(String receiveDeviceType) {
        this.receiveDeviceType = receiveDeviceType;
    }

    public String getUrlType() {
        return urlType;
    }

    public void setUrlType(String urlType) {
        this.urlType = urlType;
    }

    public String getUrlPath() {
        return urlPath;
    }

    public void setUrlPath(String urlPath) {
        this.urlPath = urlPath;
    }

    public String getDesktopUrlPath() {
        return desktopUrlPath;
    }

    public void setDesktopUrlPath(String desktopUrlPath) {
        this.desktopUrlPath = desktopUrlPath;
    }

    public String getMessageStatus() {
        return messageStatus;
    }

    public void setMessageStatus(String messageStatus) {
        this.messageStatus = messageStatus;
    }

    public String getStatusColor() {
        return statusColor;
    }

    public void setStatusColor(String statusColor) {
        this.statusColor = statusColor;
    }

    public String getIsForceTips() {
        return isForceTips;
    }

    public void setIsForceTips(String isForceTips) {
        this.isForceTips = isForceTips;
    }

    public String getFsMsgType() {
        return fsMsgType;
    }

    public void setFsMsgType(String fsMsgType) {
        this.fsMsgType = fsMsgType;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getFileKey() {
        return fileKey;
    }

    public void setFileKey(String fileKey) {
        this.fileKey = fileKey;
    }

    public String getJtgsId() {
        return jtgsId;
    }

    public void setJtgsId(String jtgsId) {
        this.jtgsId = jtgsId;
    }

    public String getButtonText() {
        return buttonText;
    }

    public void setButtonText(String buttonText) {
        this.buttonText = buttonText;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getSourceUrl() {
        return sourceUrl;
    }

    public void setSourceUrl(String sourceUrl) {
        this.sourceUrl = sourceUrl;
    }

    public String getUserIds() {
        return userIds;
    }

    public void setUserIds(String userIds) {
        this.userIds = userIds;
    }

    public String getDeptIds() {
        return deptIds;
    }

    public void setDeptIds(String deptIds) {
        this.deptIds = deptIds;
    }

    public String getMsgType() {
        return msgType;
    }

    public void setMsgType(String msgType) {
        this.msgType = msgType;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public String getMdText() {
        return mdText;
    }

    public void setMdText(String mdText) {
        this.mdText = mdText;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getPcUrl() {
        return pcUrl;
    }

    public void setPcUrl(String pcUrl) {
        this.pcUrl = pcUrl;
    }

    public String getMobileUrl() {
        return mobileUrl;
    }

    public void setMobileUrl(String mobileUrl) {
        this.mobileUrl = mobileUrl;
    }

    public String getBgColor() {
        return bgColor;
    }

    public void setBgColor(String bgColor) {
        this.bgColor = bgColor;
    }

    public List<OapiMessageCorpconversationAsyncsendV2Request.Form> getListFrom() {
        return listFrom;
    }

    public void setListFrom(List<OapiMessageCorpconversationAsyncsendV2Request.Form> listFrom) {
        this.listFrom = listFrom;
    }

    public String getBodyTitle() {
        return bodyTitle;
    }

    public void setBodyTitle(String bodyTitle) {
        this.bodyTitle = bodyTitle;
    }

    public String getFileCount() {
        return fileCount;
    }

    public void setFileCount(String fileCount) {
        this.fileCount = fileCount;
    }

    public String getRichNum() {
        return richNum;
    }

    public void setRichNum(String richNum) {
        this.richNum = richNum;
    }

    public String getRichUnit() {
        return richUnit;
    }

    public void setRichUnit(String richUnit) {
        this.richUnit = richUnit;
    }

    public String getFormKey() {
        return formKey;
    }

    public void setFormKey(String formKey) {
        this.formKey = formKey;
    }

    public String getFormValue() {
        return formValue;
    }

    public void setFormValue(String formValue) {
        this.formValue = formValue;
    }

    public String getBtnOrientation() {
        return btnOrientation;
    }

    public void setBtnOrientation(String btnOrientation) {
        this.btnOrientation = btnOrientation;
    }

    public List<OapiMessageCorpconversationAsyncsendV2Request.BtnJsonList> getBtnJsonList() {
        return btnJsonList;
    }

    public void setBtnJsonList(List<OapiMessageCorpconversationAsyncsendV2Request.BtnJsonList> btnJsonList) {
        this.btnJsonList = btnJsonList;
    }

    public String getTwType() {
        return twType;
    }

    public void setTwType(String twType) {
        this.twType = twType;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public static DingTalkBuild dingTalkBuild() {
        return new DingTalkBuild();
    }

    private static class DingTalkBuild {

    }

    public static WeChatMsgBuild weChatMsgBuild() {
        return new WeChatMsgBuild("","","","","","","","");
    }

    public static class WeChatMsgBuild {
        /**
         * 接收用户 如果值为@all 则发送给全部的人
         */
        private String userIds;
        /**
         * 内容
         */
        private String content;

        /**
         * 消息类型  钉钉 ：文字：WZ  图片：TP 语音：YY  文件：WJ markdown:MD OA:OA 卡片：KP 链接LJ
         *         微信 ：文字：WZ  图文：TW 图片：TP 语音：YY 视频：SP 文件：WJ
         *         welink：普通卡片 common 、 //TODO 应用卡片 wecode 、图片消息 image 、图文消息 news
         *
         */
        /**
         * 图文类型  UEditor 编辑器内容 || HTML || URL 链接
         */
        private String twType;
        /**
         * 图文类型  UEditor 编辑器内容 || HTML || URL 链接
         */
        private String msgType;
        /**
         * 标题
         */
        private String title;
        /**
         * 作者
         */
        private String author;
        /**
         * 作者
         */
        private String remark;
        /**
         * 文件 语音 图片 表情包 视频 地址
         */
        private String fileKey;

        public WeChatMsgBuild(String userIds, String content, String twType, String msgType, String title, String author, String remark, String fileKey) {
            this.userIds = userIds;
            this.content = content;
            this.twType = twType;
            this.msgType = msgType;
            this.title = title;
            this.author = author;
            this.remark = remark;
            this.fileKey = fileKey;
        }

        public WeChatMsgBuild setUserIds(String userIds) {
            this.userIds = userIds;
            return this;
        }

        public WeChatMsgBuild setContent(String content) {
            this.content = content;
            return this;
        }

        public WeChatMsgBuild setTwType(String twType) {
            this.twType = twType;
            return this;
        }

        public WeChatMsgBuild setMsgType(String msgType) {
            this.msgType = msgType;
            return this;
        }

        public WeChatMsgBuild setTitle(String title) {
            this.title = title;
            return this;
        }

        public WeChatMsgBuild setAuthor(String author) {
            this.author = author;
            return this;
        }

        public WeChatMsgBuild setRemark(String remark) {
            this.remark = remark;
            return this;
        }

        public WeChatMsgBuild setFileKey(String fileKey) {
            this.fileKey = fileKey;
            return this;
        }

        public MessageVo build(){
            return new MessageVo(weChatMsgBuild());
        }

    }
    private MessageVo (WeChatMsgBuild builder){
        this.userIds = builder.userIds;
        this.content = builder.content;
        this.twType = builder.twType;
        this.msgType = builder.msgType;
        this.title = builder.title;
        this.author = builder.author;
        this.remark = builder.remark;
        this.content = builder.content;
        this.fileKey = builder.fileKey;
    }

}
